package com.android.nfctouch.ui.activity;

import android.content.Intent;
import android.text.TextUtils;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.android.baselibrary.interface_.OkHttpCallBack;
import com.android.baselibrary.responce.BaseResponce;
import com.android.baselibrary.tool.CommToast;
import com.android.baselibrary.util.Util;
import com.android.baselibrary.view.Comm_EditView;
import com.android.baselibrary.view.Comm_HeadView;
import com.android.baselibrary.view.MultiStateView;
import com.android.nfctouch.R;
import com.android.nfctouch.constants.Constants;
import com.android.nfctouch.manager.API_Manager;

import butterknife.BindView;
import butterknife.OnClick;

public class CommInputActivity extends BaseActivity {

    @BindView(R.id.multiplestatusView)
    MultiStateView multiplestatusView;
    @BindView(R.id.comm_title)
    Comm_HeadView comm_title;
    @BindView(R.id.tv_tips)
    TextView tv_tips;
    @BindView(R.id.et_content)
    Comm_EditView et_content;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_comm_input;
    }

    @Override
    protected void initView() {
        String title = getIntent().getStringExtra("title");
        String tips = getIntent().getStringExtra("tips");
        String hint = getIntent().getStringExtra("hint");
        int length = getIntent().getIntExtra("length",20);
        boolean isMultipleLine = getIntent().getBooleanExtra("isMultipleLine", false);

        comm_title.setTitle(title);
        tv_tips.setText(tips);
        et_content.setHint(hint);
        et_content.setMaxLength(length);

        if(isMultipleLine)
        {
            et_content.setIsMultipleLines(true);
            et_content.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Util.dip2px(mContext,150)));
        }
        else
        {

        }

    }

    @Override
    protected void initData() {

    }

    @OnClick({R.id.tv_submit})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.tv_submit:
                String text = et_content.getText();
                if (TextUtils.isEmpty(text)) {
                    CommToast.showToast(mContext, "请输入内容");
                    return;
                }
                Intent intent = new Intent();
                intent.putExtra("text", text);
                setResult(100, intent);
                finish();
                break;
        }
    }
}
